import { createRouter, RouteRecordRaw, createWebHistory } from 'vue-router'
import autoAddRoute from './addRoute'
import HelloWorld from '@/components/HelloWorld.vue'

export const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: HelloWorld,
    meta: {
      title: 'home',
      icon: 'el-icon-s-home'
    }
  },
  {
    path: '/about',
    component: () => import('views/About/About.vue'),
    name: 'about',
    meta: {
      title: 'about',
      icon: 'el-icon-location'
    },
    children: [
      {
        path: 'foo',
        component: () => import('views/About/Foo.vue'),
        meta: {
          title: 'foo',
          icon: 'el-icon-setting'
        }
      }
    ]
  },
  {
    path: '/bar',
    component: () => import('views/Bar.vue'),
    meta: {
      title: 'bar',
      icon: 'el-icon-setting'
    }
  },
  {
    path: '/user',
    component: () => import('views/users/index.vue'),
    meta: {
      title: '用户列表',
      icon: 'el-icon-user-solid'
    },
    children: [
      {
        name: 'userEdit',
        path: 'edit/:id',
        component: () => import('views/users/Edit.vue'),
        meta: {
          title: '编辑'
        }
      },
      {
        name: 'userCreate',
        path: 'create',
        component: () => import('views/users/Create.vue'),
        meta: {
          title: '编辑'
        }
      }
    ]
  }
]

export const router = createRouter({
  history: createWebHistory(),
  routes
})

autoAddRoute()